---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(dplyr)
library(plotly)
library(p8105.datasets)
```
```{r}
data("rest_inspec")
rest_inspec2 =
rest_inspec %>%
select(boro, cuisine_description, dba, zipcode, violation_code, violation_description, grade, grade_date, critical_flag, score) %>%
mutate(zipcode = as.character(zipcode)) %>%
filter(!is.na(grade),!is.na(violation_description), !is.na(score)) %>%
filter(boro == "STATEN ISLAND",
!grade == "Not Yet Graded",
!grade == "P",
!grade == "Z")
```
Row
-------------------------------------
### Chart 1
```{r}
#Number of restaurants per grade (Bar Graph)
rest_inspec2 %>%
count(grade) %>%
mutate(grade = fct_reorder(grade, n)) %>%
plot_ly(x = ~grade , y = ~n, color = ~grade, type = "bar", colors = "viridis")
```
### Chart 2
```{r}
#ZIPCODE VS CUISINE (scatter)
rest_inspec2 %>%
plot_ly(
x = ~zipcode, y = ~cuisine_description,
type = "scatter", text = ~dba,
mode = "markers",
color = ~grade, alpha = 0.5)
```
Row
-------------------------------------
### Chart 3
```{r}
#GRADE VS SCORE (box)
rest_inspec2 %>%
plot_ly(x = ~grade, y = ~score, color = ~grade, type = "box", colors = "viridis")
```
### Chart 4
```{r}
#ZIPCODE VS SCORE
rest_inspec2 %>%
plot_ly(x = ~zipcode, y = ~score, color = ~grade, type = "scatter",
text = ~dba, mode = "markers", colors = "viridis")
```